Skip to content

Comments

feat: loop prop and public methods#2

Open
bradmartin wants to merge 1 commit intoeharrison:masterfrom
bradmartin:master
Open

feat: loop prop and public methods#2
bradmartin wants to merge 1 commit intoeharrison:masterfrom
bradmartin:master

Conversation

@bradmartin
Copy link
Contributor

  • Adds loop prop so you can play the animation once or allow looping.
  • Move play/pause methods to public for more control of playback.

This allows the following behavior:

 Image(uiImage: self.lottie.image)
                        .resizable()
                        .scaledToFit()
                        .onAppear {
                            self.lottie.loop = false
                            self.lottie.loadAnimationFromFile(filename: "green-success")
                            
                            DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
                                self.lottie.play()
                                self.lottie.loop = true
                            }
                        }

So the animation plays once (since loop is false) then after a delay play() is called to start the animation again and loop = true to allow looping to occur.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant